Imports System.Text

Public Class RecordNavigator
    Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents ltrNavigator As System.Web.UI.WebControls.Literal

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub BuildNavigator()
        Dim sb As StringBuilder = New StringBuilder

        If RequestContext.ChainOfID.Length > 0 Then
            Dim i As Int32
            ' RequestContext.SelectedIDs.Count always >= 2
            For i = 0 To RequestContext.SelectedIDs.Count - 2
                Dim id As String = Convert.ToString(RequestContext.SelectedIDs(i))

                If (id.Equals(RequestContext.BulkOrderID.ToString())) Then
                    sb.AppendFormat("<span class=""Selected"">[{0}]</span>", id)
                Else
                    sb.AppendFormat("<a href=""{0}"">[{1}]</a>", _
                        ResolveUrl(UrlBuilder.GetBODetailUrl(RequestContext.SupplierCode, Integer.Parse(id), RequestContext.ChainOfID, False, RequestContext.Changed, 0)), id)
                End If

                sb.Append("&nbsp;&nbsp;")
            Next
        Else
            sb.Append("<span class=""Selected"">[NEW RECORD]</span>")
        End If

        ltrNavigator.Text = sb.ToString()
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            BuildNavigator()
        End If
    End Sub

End Class
